import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import "default-passive-events";
// vuex 数据存储
import store from "./store";
// element-plus 组件库
import element from "./plugins/element";
// 页面粒子效果
import VueParticles from "vue-particles";
// excel表格导出插件
import XLSX from "xlsx";
// 文件下载插件
import FileSaver from "file-saver";
// 全局配置
import Config from "./assets/js/config";
// 全局基础类库
import Base from "./assets/js/base";
// 全局方法库
import Function from "./assets/js/function.js";
// 导入全局样式
import "./assets/css/base.scss";
// 导入图标库
import "./assets/fonts/iconfont.css";

// 导入ajax请求
import axios from "axios";
// 配置请求的根路径
axios.defaults.baseURL = Config.baseURL;
// 添加请求头信息
axios.interceptors.request.use(config => {
  // const tokenType = Cookies.get('token_type') || ''
  // const token = Cookies.get('token') || ''
  const token = localStorage.getItem("token") || "";
  const tokenType = localStorage.getItem("token_type") || "";
  config.headers.Authorization = tokenType + " " + token;
  config.headers.apikey = Config.apikey;
  return config;
});
const Vue = createApp(App);
element(Vue);
Vue.config.globalProperties.$http = axios;
Vue.config.globalProperties.$base = Base;
Vue.config.globalProperties.$config = Config;
Vue.config.globalProperties.$FileSaver = FileSaver;
Vue.config.globalProperties.$XLSX = XLSX;
Vue.use(store)
  .use(router)
  .use(VueParticles)
  .use(Function)
  .mount("#app");
